/* 
 * Spring mixin mybatis frame code general
 * Fu(iknoweth@yahoo.com) All rights reserved 
 * 
 */
package com.pricl.biz.system.controller;

import java.util.List;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.google.common.collect.Lists;
import com.pricl.frame.cache.CacheListConstant;
import com.pricl.frame.core.R;
import com.pricl.frame.util.RedisUtil;

/**
 * <p>
 * <strong>码表</strong>Access Controller
 * </p>
 *
 */
@RequestMapping("/system")
@Controller
public class SystemController {
	
	/**
	 * 清空所有redis app缓存。不包括session等
	 * @return
	 */
	@RequestMapping(value = "/clearCache", method = RequestMethod.POST)
	public @ResponseBody R clearCache() {
		List<String> keys = Lists.newArrayList(
								CacheListConstant.ADVERTINFO_SERVICE_KEY,
								CacheListConstant.ARTICLE_CACHE,
								CacheListConstant.COMMON_SERVICE_KEY,
								CacheListConstant.LETTER_CACHE_KEY,
								CacheListConstant.ZHAOSHANG_COMPANY_SERVICE_KEY,
								CacheListConstant.ZHAOSHANG_PROJECT_SERVICE_KEY
							);
		for (String key : keys) {
			RedisUtil.batchDel(key + "*");
		}
		return R.ok("清空app端缓存成功");
	}
}
